home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
errins.zip
/
ERRINSP.DOC
< prev
next >
Wrap
Text File
|
1992-04-01
|
17KB
|
393 lines
Error Inspector version 1.0
Diagnostic error handler for Clipper 5.01
Copyright (c) 1991, 1992 Nantucket Corporation. All rights reserved
The Error Inspector is a diagnostic error handler for Clipper 5.0.
It can be used to diagnose errors during development or as an
educational aid to learn about Clipper's Error System. As a
developer, you stand to benefit from using this replacement error
handler during production, but not necessarily in a final shipping
version of your software. Because this is a development utility,
we've made it simple for you to use the Error Inspector in your
applications and remove it with a minimum of effort.
========================================================================
1. Contents
The following topics are covered in this documentation file:
1.Contents
2.Overview of the Error Inspector
3.Installing the Error Inspector Files
4.Linking the Error Inspector Files
5.Programming for the Error Inspector
6.Implementation Notes
========================================================================
2. Overview of the Error Inspector
The Error Inspector is supplied as an alternate error handler
which may be used as a replacement for Clipper 5.0's default error
handler DefError(). When an error is encountered, the Error
Inspector intervenes and an initialization window is displayed on
the screen. Once initialization is complete, the Error object's
instance variables are displayed and a lightbar menu appears at
the top of the screen. The menu may be activated at any time by
pressing F10.
The menu consists of the following submenus:
Response
--------
This menu allows you to choose the possible responses to an error
condition. Only the applicable responses to the condition will be
available; all others will be greyed out.
Break (Ctrl-B) - This option executes a BREAK command, passing the
current Error object to the outer enclosing sequence. Break is
always available.
Default - Some Error objects set the instance variable
oError:canDefault to true, indicating that some default recovery
is possible. When the Default option is availble, selecting it
will terminate the Error Inspector and request that the error be
handled in the default manner.
Retry (Ctrl-R) - The Retry option is available only when the
oError:canRetry instance variable is set to true, indicating that
the operation generating the error can be retried. Selecting the
Retry option will terminate the Error Inspector and retry the
operation that failed.
Substitute - If selected, you will be prompted for a substitute
value to return to the subsystem generating the error. Enter any
macro-compilable Clipper expression. Note that strings must be
enclosed in quotes, and LOCAL and STATIC variables can not appear
in this expression. The Error Inspector will terminate and return
the substitute value to the code generating the error.
Quit (Alt-F4) - Quit returns you to DOS by executing a QUIT
command. QUIT automatically closes all files and removes VM
temporary swapfiles, so this is not a particularly dangerous way
to exit the application. However, you may find that many of your
program components will not respond happily to half-written
transactions.
View
----
All of the options under the View menu change the contents of the
desktop. The up and down arrows allow you to scroll through the
desktop's data, and a scroll bar to the right indicates your
current position in the viewed data. A checkmark to the left of a
View menu option indicates that the option is currently being
displayed on the desktop.
Callstack (Ctrl-F1) - The Callstack is a list containing the names
and line numbers of all pending activations at the point in the
application where the error occurred. The topmost activation
listed in the callstack is from the Error Inspector (ERRINSP). The
error that the Error Inspector is reporting occured just below the
(b)ERRORSYS activation.
Description (Ctrl-F2) - The Description view polls the database of
descriptions provided with the Error Inspector (ErrInfo.dbf,
ErrInfo.dbt, and ErrInfo.ntx). The Error Inspector will display
the appropraiate description from the Clipper 5.01 Norton
Guides(tm) for the error encountered. If the database is not
found, then the Description option is not selectable (see
"Implementation Notes" at the end of this file for more
information).
Environment (Ctrl-F3) - The Environment view shows the level of
certain system resources when the error occurred. Available memory
levels, disk space, file handles, and other resources are found
here. Remember that these values reflect the system's state just
after the error occurred and do not necessarily represent the
current Error Inspector state.
Error Object (Ctrl-F4) - This option shows the settings of all of
the instance variables in the Error object. A complete description
for each of these can be found in The Guide to Clipper Norton
Guide supplied with Clipper 5.01. Note that, where possible,
numerics are expanded to descriptions (i.e. if e:genCode equals
14, the Error Inpector displays "14:No Variable").
Sets (Ctrl-F5) - Just as the Environment view shows information
about system-wide resources, the Sets option shows information
about Clipper-wide resources. See the SET() funciton description
in the The Guide to Clipper Norton Guide supplied with Clipper
5.01 for information about each setting shown here.
Work Areas (Ctrl-F6) - The Work Areas option provides information
on all open database work areas at the time the error occurred.
File structures, indexes, current record information, and select
status are all profiled on this screen.
Options
-------
The Options menu is where miscellaneous options are located.
NETERR() - By selecting NETERR() you toggle the NETERR() flag on
or off. When NETERR() is set to true, a checkmark appears to the
left of the option name. NETERR() is completely described in The
Guide to Clipper Norton Guide supplied with Clipper 5.01.
DOS Shell (Ctrl-O) - By selecting this menu option, you can
temporarily exit your application and return to DOS. When you type
the EXIT command from the DOS shell, you are returned to the Error
Inpector screen. See the "Implementation Notes" at the end of this
document if you do not have enough memory to shell to DOS.
View App Screen (Ctrl-V) - Before the Error Inspector begins
setting up all of the views, it saves the screen image. You may
look at the image at any time with this option. Any key will
return you to the Error Inspector.
Write Log File (Ctrl-W) - This option allows you to write the
contents of all views to a text file. A default file name is
created from the date and time with the extention (.rip). You may
write the log file to any file you wish. If you choose a filename
that exists, you will be asked if you wish to overwrite the file.
========================================================================
3. Installing Error Inspector Files
Prior to installation, the Error Inspector consists of the
following two files:
-------------------------------------------------------
Filename Description
-------------------------------------------------------
ERRINSP.DOC Documentation (This file)
ERRINSP.ZIP The Error Inspector
-------------------------------------------------------
To install the Error Inspector files on your machine:
1. Create the \ERRINSP directory:
C>MD \ERRINSP
2. Copy this file to the \ERRINSP directory:
C>COPY [d:][pathspec]ERRINSP.DOC \ERRINSP\*.*
3. Unzip the error inspector files:
C>CD \ERRINSP
C>PKUNZIP [d:][pathspec]ERRINSP
These are the files in the Error Inspector distribution (.zip)
file, ErrInsp.zip:
-------------------------------------------------------
Filename Description
-------------------------------------------------------
ERRDEMO.PRG Demonstration program
ERRDEMO.RMK RMAKE script for linking the demonstration
ERRINSP.PRG ErrorSys() replacement which installs the error
inspector as the default error handler
ERRINSP.OBJ ErrInsp.prg, in object code form
ERRINSP.LIB Support functions required by the error inspector.
ERRINFO.DBF Error Information database containing descriptions
of errors generated by Clipper 5.0's various
subsystems.
ERRINFO.DBT Memo file for the Error Information database.
ERRINFO.NTX Index file for the Error Information database.
SAMPLE.RIP Sample output
-------------------------------------------------------
Once these files are in your \ERRINSP directory, you should create
and run the demo program. An RMAKE file has been provided for this
purpose. You will have to tell the RMAKE file where your CLIPPER
root directory is with the /dclipdir: option (usually
C:\CLIPPER5\):
C>RMAKE ERRDEMO /dclipdir:<clipper root> [/dpll]
When you run the demonstration program, you will be presented with
a menu of errors that can be created -- the Error du Jour. When
you select an error, the demo program will generate the error,
thereby invoking the Error Inspector (see "Overview of the Error
Inspector" for more information).
========================================================================
4. Linking the Error Inspector into Your Application
The Error Inspector consists of two parts: a public interface, and
a library of support routines. The public interface (ErrInsp.prg &
ErrInsp.OBJ) contains startup code that installs the Error
Inspector as the default error handler. The function ERRORSYS() in
ErrInsp.prg posts the Error Inspector root function as the new
default ERRORBLOCK(). For this reason, ErrInsp.OBJ must appear
last in your object list, and you must not have previously defined
ERRORSYS() in your application.
Here are the common ways that the Error Inspector can be linked
into your application:
1. To link with .RTLink using positional syntax:
C>RTLINK <appObjectList> ERRINSP,,, <systemLibList> ERRINSP;
2. To link with .RTLink using freeformat syntax:
C>RTLINK FI <appObjectList>,ERRINSP LIB <systemLibList>,ERRINSP
3. To link with .RTLink using Base50.PLL and freeformat syntax:
C>RTLINK FI <appObjectList>,ERRINSP LIB <systemLibList>,ERRINSP
/PLL:BASE50.PLL
4. To link using MS-Link version 3.65 and above:
C>LINK <appObjectList> ERRINSP,,, <systemLibList> ERRINSP /NOD
/NOE /SE:512;
Note: These link commands all assume that the LIB, OBJ, and PLL
environment variables are set to the standard locations.
========================================================================
5. Programming for the Error Inspector
While there are no special code requirements for using the Error
Inspector, you can write your programs to be more "error handler
aware."
The simplest and most dramatic change you can make is to simply
surround your main menu with a BEGIN SEQUENCE...END structure. It
is also a good idea to provide some cleanup code in the RECOVER
section of this BEGIN SEQUENCE...END. This will allow you to issue
a BREAK(e) after a minor error has occured, yet still remain in
the program with reasonable assuredness that the error condition
will no longer affect you.
The complexity of your RECOVER routine is up to you, but remember
that you have the Error object's information to guide you in
choosing a complete recovery strategy. This could be as simple as
falling through to the end of the loop, or as complex as
reindexing or rebuilding your databases.
Here is a skeletal example of this strategy:
DO WHILE !lTerminated
BEGIN SEQUENCE
.
<application setup>
.
Main() // Main menu, event loop, whatever...
.
<application termination code>
.
// Made it through sucessfully
lTerminated := .T.
RECOVER USING e
.
<recovery code>
.
IF <condition fatal>
lTerminated := .T.
ENDIF
END SEQUENCE
ENDDO
.
.<application clean up code>
.
More information on the use of the Error Handler in Clipper can be
found in the Clipper Manuals; the Norton Guides to Clipper;
Nantucket News V5 N2, September/October 1990, p3-6; Nantucket News
V5 N4, January/February 1991, p13-22, and The Nantucket Technical
Series, "Error Handling Strategies."
========================================================================
6. Implementation Notes
-----------------------------------------------------------------
How the Error Inspector locates error descriptions
When you choose View-Description (Ctrl-F2), the Error Inspector
looks for ErrInfo.dbf, ErrInfo.dbt, and ErrInfo.ntx to find the
complete description of the error. If for some reason, the Error
Inspector is unable to locate these files, the Description option
will be unavailable.
If this occurs, you may have installed the Error Inspector in a
drive and directory other than C:\ERRINSP. In order to point to
the correct location of the database files, the EI_ERRINFO_PATH
manifest constant in ErrInsp.prg should be modified to reflect the
proper path.
After modification, you will need to recompile ErrInsp.prg. See
the instructions below.
Note that if, for some reason, the Error Inspector's database,
memo, or index files are corrupt, the only repair mechanism
available is to unzip them from the distribution files.
-----------------------------------------------------------------
Freeing more memory to shell to DOS
There are several third-party libraries that allow you to shell to
DOS while first swapping used low memory to disk or EMS. If you
own one of these products, and would like to take advantage of
their ability to shell to DOS while maximizing free memory, you
need only change the return value of ShellBlock() in ErrInsp.prg.
The Error Inspector retreives the code block returned by
ShellBlock() and EVALs it when a shell to DOS is requested. Note
that the Error Inspector will ensure that the cursor is on and the
screen is saved before ShellBlock() is EVALed. If you must
generate an error from your ShellBlock(), issue a BREAK(e).
After modification, you will need to recompile ErrInsp.prg. See
the instructions below.
-----------------------------------------------------------------
Instructions for recompiling ErrInsp.prg
Use the following Clipper command to recompile ErrInsp.prg:
C>CLIPPER ERRINSP /n /m /w
-----------------------------------------------------------------
Errors Encountered from within the Error Inspector,
... or When it really hits the fan ...
If, for some reason, the Error Inspector encounters a condition it
is not prepared to deal with, an ALERT() box is displayed:
The Error Inspector is unable to continue.
<e:subSystem>/<e:subcode>: <e:description>
You then have the option to QUIT or BREAK. If you choose to QUIT,
you will find yourself at the DOS prompt. When selecting the
BREAK, program control is passed to the nearest BEGIN
SEQUENCE...END construct. If your application does not include
such a statement block, execution will terminate, returning to
DOS.
-----------------------------------------------------------------
The Error Inspector Team
------------------------
The Error Inspector was originally developed for the Fall 1991
Developer Conference. It is writtten entirely in Clipper 5.01
Design: Craig Ogg and Jesse Srogoncik
Implementation: Jesse Srogoncik
Documentation: Terry McConnell
Consultation: Savannah Brentnall, Robert DiFalco,
Scott McIntosh, Terry McConnell, David Morgan,
Phil Schwartz, and Chris White
* * *